# source files

SRC = Tree/ZipTree.cpp \
      Tree/ZipNode.cpp \
      log/ConsoleLogger.cpp \
      log/FileLogger.cpp \
      log/Logger.cpp \
      log/LoggerManager.cpp \
      Compressor/Compressor.cpp \
      Compressor/FileHeader.cpp\
      algorithms/LZ77.cpp \
      utils/Utils.cpp \
      utils/CRC32.cpp \
      utils/ZipBrowser.cpp\
      softZip.cpp

OBJ = $(patsubst %.cpp,obj/%.o,$(SRC))

OUT = libsoftzip.a

#include directories
INCLUDES = -I.\
           -Iglist \
           -I../src/gtree

#library paths
LIBS = -L/user/local/lib -lm 

#Compiler flags
CCFLAGS = -fPIC -g -Wall
LDFLAGS = rcs

#compiler
CCC = g++
AR = ar

default: $(OUT)

$(OBJ): | obj

obj:
	@echo creating objects directory $@
	@mkdir -p $@
	@mkdir -p $(patsubst %/, $@/%, $(sort $(dir $(SRC))))

obj/%.o : %.cpp
	$(CCC) $(INCLUDES) $(CCFLAGS) -c $< -o $@

#archive the library
$(OUT):$(OBJ)
	@mkdir -p ../lib
	$(AR) $(LDFLAGS) ../lib/$(OUT) $(OBJ)

clean:
	rm -f $(OBJ)
	rm -rf obj
	rm -rf ../lib
